package com.ruoyi.employee.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.employee.domain.vo.EducationExperienceVo;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.employee.domain.EducationExperience;
import com.ruoyi.employee.service.IEducationExperienceService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 员工档案Controller
 * 
 * @author ruoyi
 * @date 2025-05-30
 */
@RestController
@RequestMapping("/experience/experience")
public class EducationExperienceController extends BaseController
{
    @Autowired
    private IEducationExperienceService educationExperienceService;

    /**
     * 查询员工档案列表
     */
    @PreAuthorize("@ss.hasPermi('experience:experience:list')")
    @GetMapping("/list")
    public TableDataInfo list(EducationExperienceVo educationExperienceVo)
    {
        startPage();
        List<EducationExperienceVo> list = educationExperienceService.selectEducationExperienceList(educationExperienceVo);
        return getDataTable(list);
    }

    /**
     * 导出员工档案列表
     */
    @PreAuthorize("@ss.hasPermi('experience:experience:export')")
    @Log(title = "员工档案", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EducationExperienceVo educationExperience)
    {
        List<EducationExperienceVo> list = educationExperienceService.selectEducationExperienceList(educationExperience);
        ExcelUtil<EducationExperienceVo> util = new ExcelUtil<EducationExperienceVo>(EducationExperienceVo.class);
        util.exportExcel(response, list, "员工档案数据");
    }

    /**
     * 获取员工档案详细信息
     */
    @PreAuthorize("@ss.hasPermi('experience:experience:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(educationExperienceService.selectEducationExperienceById(id));
    }

    /**
     * 新增员工档案
     */
    @PreAuthorize("@ss.hasPermi('experience:experience:add')")
    @Log(title = "员工档案", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EducationExperience educationExperience)
    {
        return toAjax(educationExperienceService.insertEducationExperience(educationExperience));
    }

    /**
     * 修改员工档案
     */
    @PreAuthorize("@ss.hasPermi('experience:experience:edit')")
    @Log(title = "员工档案", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EducationExperience educationExperience)
    {
        return toAjax(educationExperienceService.updateEducationExperience(educationExperience));
    }

    /**
     * 删除员工档案
     */
    @PreAuthorize("@ss.hasPermi('experience:experience:remove')")
    @Log(title = "员工档案", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(educationExperienceService.deleteEducationExperienceByIds(ids));
    }

    /**
     * 员工学历人数
     */
    @PreAuthorize("@ss.hasPermi('experience:experience:list')")
    @GetMapping("/count")
    public AjaxResult count(){
        return success(educationExperienceService.countEducationExperience());
    }
}
